using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Shop.Member;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class Member_Shop_UserInfoList : Member, IRequiresSessionState
{
	protected ScriptManager ScriptManager1;
	protected Literal UserName;
	protected TextBox TxtU_TrueName;
	protected RequiredFieldValidator RequiredFieldValidator2;
	protected Label Identify_truename_tips;
	protected Literal labemail;
	protected Literal L_Province_City;
	protected DropDownList Province;
	protected DropDownList City;
	protected DropDownList ddlArea;
	protected UpdatePanel UpdatePanel1;
	protected TextBox TxtU_Address;
	protected RequiredFieldValidator RequiredFieldValidator3;
	protected TextBox ZipCode;
	protected RequiredFieldValidator RequiredFieldValidator4;
	protected RegularExpressionValidator RegularExpressionValidator3;
	protected RadioButtonList RadioU_ContactType;
	protected TextBox TxtU_MobilePhone;
	protected HyperLink HyperLink2;
	protected RegularExpressionValidator RegularExpressionValidator4;
	protected TextBox TxtU_HomePhone;
	protected RegularExpressionValidator RegularExpressionValidator5;
	protected DropDownList RadioU_IdentifyType;
	protected TextBox TxtU_IDCard;
	protected Label identify_IDcard_tips;
	protected Label IDcard_msg;
	protected RegularExpressionValidator RegularExpressionValidator1;
	protected TextBox OICQ;
	protected RegularExpressionValidator RegularExpressionValidator2;
	protected HtmlTableRow ShowQQ;
	protected TextBox Skype;
	protected HtmlTableRow Tr1;
	protected TextBox Msn;
	protected HtmlTableRow Tr2;
	protected TextBox Yahoo;
	protected HtmlTableRow Tr3;
	protected TextBox Taobaowangwang;
	protected HtmlTableRow ShowWW;
	protected Image IdentifyStatus;
	protected HyperLink GoIdentify;
	protected Image IdentifyPassStatus;
	protected Button btnsave;
	private Shop_City _mycity = null;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected Shop_City mycity
	{
		get
		{
			Shop_City mycity;
			if (this._mycity == null)
			{
				this._mycity = new Shop_City(this.conn);
				mycity = this._mycity;
			}
			else
			{
				mycity = this._mycity;
			}
			return mycity;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			if (this.conn.ExecuteCount("Select count(UserInfoID) From HL_UserInfo Where UserID=" + base.user.UserID) <= 0)
			{
				this.WriteErrMsg(Language.GetMemberMsg("Common/ZhuoQing", new string[0]), Language.Get("Shop/OpenShop/UserInfoErr"), "MyShop.aspx");
			}
			else
			{
				if (base.shopconfig["ShowQQ"].ToString() == "1")
				{
					this.OICQ.Visible = true;
				}
				else
				{
					this.OICQ.Visible = false;
				}
				if (base.shopconfig["ShowWW"].ToString() == "1")
				{
					this.Taobaowangwang.Visible = true;
				}
				else
				{
					this.Taobaowangwang.Visible = false;
				}
				this.BindProList();
				this.BindPages();
			}
		}
	}
	protected void BindProList()
	{
		this.Province.DataSource = this.mycity.GetAllProvince();
		this.Province.DataBind();
	}
	protected void BindCityList()
	{
		this.City.DataSource = this.mycity.GetCity(this.Province.SelectedValue);
		this.City.DataBind();
	}
	protected void SelectCity(object sender, EventArgs e)
	{
		string selectedValue = this.Province.SelectedValue;
		this.BindCityList();
		this.BindAreaList();
	}
	protected void BindAreaList()
	{
		this.ddlArea.DataSource = this.mycity.GetAllAreaByCity(this.City.SelectedValue);
		this.ddlArea.DataBind();
	}
	protected void SelectArea(object sender, EventArgs e)
	{
		this.BindAreaList();
	}
	protected void BindPages()
	{
		base.user.GetUserInfor();
		this.UserName.Text = base.user.UserName;
		this.labemail.Text = base.user.UserEmail;
		this.Province.SelectedValue = base.user.UserInforRes["Province"].ToString();
		this.BindCityList();
		this.City.SelectedValue = base.user.UserInforRes["City"].ToString();
		this.BindAreaList();
		this.ddlArea.SelectedValue = base.user.UserInforRes["CMArea"].ToString();
		this.L_Province_City.Text = string.Concat(new string[]
		{
			base.user.UserInforRes["Province"].ToString(),
			" ",
			base.user.UserInforRes["City"].ToString(),
			" ",
			base.user.UserInforRes["CMArea"].ToString()
		});
		this.TxtU_TrueName.Text = base.user.UserInforRes["TrueName"].ToString();
		this.TxtU_Address.Text = base.user.UserInforRes["Address"].ToString();
		this.ZipCode.Text = base.user.UserInforRes["ZipCode"].ToString();
		this.RadioU_ContactType.SelectedValue = base.user.UserInforRes["ContactType"].ToString();
		this.TxtU_MobilePhone.Text = base.user.UserInforRes["MobilePhone"].ToString();
		this.TxtU_HomePhone.Text = base.user.UserInforRes["HomePhone"].ToString();
		this.TxtU_IDCard.Text = base.user.UserInforRes["IDCard"].ToString();
		if (base.user.UserInforRes["IDCard"].ToString() != string.Empty && base.user.UserInforRes["IDCard"].ToString().Length > 11)
		{
			this.identify_IDcard_tips.Text = base.user.UserInforRes["IDCard"].ToString().Substring(0, 10) + "********";
			this.TxtU_IDCard.Visible = (this.IDcard_msg.Visible = false);
			this.identify_IDcard_tips.Visible = true;
		}
		this.OICQ.Text = base.user.UserInforRes["OICQ"].ToString();
		this.Skype.Text = base.user.UserInforRes["ShopSkype"].ToString();
		this.Msn.Text = base.user.UserInforRes["ShopMsn"].ToString();
		this.Yahoo.Text = base.user.UserInforRes["ShopYahoo"].ToString();
		this.Taobaowangwang.Text = base.user.UserInforRes["Taobaowangwang"].ToString();
		string a = base.user.UserInforRes["AuthenticationType"].ToString();
		if (a == "1")
		{
			this.IdentifyStatus.Visible = false;
			this.IdentifyPassStatus.Visible = true;
			this.IdentifyPassStatus.ImageUrl = "../Images/Identify.gif";
			this.IdentifyPassStatus.ToolTip = Text.HtmlReplace(Language.GetMemberMsg("Ventify/PassIDVentify", new string[0]));
		}
		else
		{
			if (a == "9")
			{
				this.IdentifyStatus.Visible = true;
				this.IdentifyPassStatus.Visible = false;
				this.IdentifyStatus.ImageUrl = "../Images/NoIdentify.gif";
				this.IdentifyStatus.ToolTip = Text.HtmlReplace(Language.GetMemberMsg("Ventify/IDVentifing", new string[0]));
			}
			else
			{
				if (a == "0" || a == "-1")
				{
					this.IdentifyStatus.Visible = true;
					this.IdentifyPassStatus.Visible = false;
					this.IdentifyStatus.ImageUrl = "../Images/NoIdentify.gif";
					this.IdentifyStatus.ToolTip = Text.HtmlReplace(Language.GetMemberMsg("Ventify/UnPassIDVentify", new string[0]));
				}
				else
				{
					this.IdentifyStatus.Visible = true;
					this.IdentifyPassStatus.Visible = false;
					this.IdentifyStatus.ImageUrl = "../Images/NoIdentify.gif";
					this.IdentifyStatus.ToolTip = Text.HtmlReplace(Language.GetMemberMsg("Ventify/UnPassIDVentify", new string[0]));
				}
			}
		}
	}
	protected void btnsave_Click(object sender, EventArgs e)
	{
		string text = this.Province.SelectedValue;
		string value;
		string value2;
		if (text == "")
		{
			text = base.user.UserInforRes["Province"].ToString();
			value = base.user.UserInforRes["City"].ToString();
			value2 = base.user.UserInforRes["CMArea"].ToString();
		}
		else
		{
			value = this.City.SelectedValue;
			value2 = this.ddlArea.SelectedValue;
		}
		IDbDataParameter[] myparam_infr = new IDbDataParameter[]
		{
			this.conn.CreateParameter("@TrueName", DbType.String, this.TxtU_TrueName.Text),
			this.conn.CreateParameter("@Address", DbType.String, this.TxtU_Address.Text),
			this.conn.CreateParameter("@ZipCode", DbType.String, this.ZipCode.Text),
			this.conn.CreateParameter("@ContactType", DbType.String, this.RadioU_ContactType.SelectedValue),
			this.conn.CreateParameter("@MobilePhone", DbType.String, this.TxtU_MobilePhone.Text),
			this.conn.CreateParameter("@HomePhone", DbType.String, this.TxtU_HomePhone.Text),
			this.conn.CreateParameter("@IDCard", DbType.String, this.TxtU_IDCard.Text),
			this.conn.CreateParameter("@OICQ", DbType.String, this.OICQ.Text),
			this.conn.CreateParameter("@Taobaowangwang", DbType.String, this.Taobaowangwang.Text),
			this.conn.CreateParameter("@ShopSkype", DbType.String, this.Skype.Text),
			this.conn.CreateParameter("@ShopMsn", DbType.String, this.Msn.Text),
			this.conn.CreateParameter("@ShopYahoo", DbType.String, this.Yahoo.Text),
			this.conn.CreateParameter("@Province", DbType.String, text),
			this.conn.CreateParameter("@City", DbType.String, value),
			this.conn.CreateParameter("@CMArea", DbType.String, value2)
		};
		string fields_infr = "[Province]=@Province,[City]=@City,[TrueName]=@TrueName,[Address]=@Address,[ZipCode]=@ZipCode,[ContactType]=@ContactType,[MobilePhone]=@MobilePhone,[HomePhone]=@HomePhone,[IDCard]=@IDCard,[OICQ]=@OICQ,[Taobaowangwang]=@Taobaowangwang,[ShopSkype]=@ShopSkype,[ShopMsn]=@ShopMsn,[CMArea]=@CMArea ";
		UserBll userBll = new UserBll(this.conn);
		bool flag = false;
		try
		{
			flag = userBll.UpdateUser(base.user.UserID, "", fields_infr, null, myparam_infr);
		}
		catch (Exception ex)
		{
			this.WriteErrMsg("", Language.GetMemberMsg("Common/EditFail", new string[]
			{
				ex.Message.ToString()
			}), "");
		}
		if (flag)
		{
			this.WriteSuccessMsg("", Language.GetMemberMsg("Common/EditSuccess", new string[0]), "Shop_UserInfoList.aspx");
		}
		else
		{
			this.WriteErrMsg("", Language.GetMemberMsg("Common/EditFail", new string[]
			{
				"提交数据不符合要求"
			}), "");
		}
	}
}
